//
//  STOrderTableViewCell.m
//  赛拓
//
//  Created by 王磊 on 8/7/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STOrderTableViewCell.h"
#import "STOrderBean.h"
@interface STOrderTableViewCell()

@property (nonatomic ,strong) UILabel *orderLabel;

@property (nonatomic ,strong) UILabel *checkState;

@property (nonatomic ,strong) UIImageView *iconImageView;

@property (nonatomic ,strong) UILabel *introduceLabel;

@property (nonatomic ,strong) UILabel *casLabel;

@property (nonatomic ,strong) UILabel *priceLabel;

@property (nonatomic ,strong) UILabel *countLabel;

@property (nonatomic ,strong) UILabel *desLabel;

@property (nonatomic ,strong) STOrderBean *order;

@property (nonatomic ,strong) UIView *whiteView;

@end
@implementation STOrderTableViewCell

- (void)setFrame:(CGRect)frame {
    CGFloat vertical_margin = 20 * ST_RATE;
    
    frame.size.height -= vertical_margin;
    
    frame.origin.y += vertical_margin;
    
    [super setFrame:frame];
}

- (void)configSubViews {
    [super configSubViews];
    
    self.backgroundColor = ST_CLEAR_COLOR;
    
    UILabel *orderLabel = [UILabel new];
    
    self.orderLabel = orderLabel;
    
    orderLabel.textAlignment = NSTextAlignmentLeft;
    
    orderLabel.backgroundColor = ST_WHITE_COLOR;
    
    orderLabel.font = ST_13_FONT;
    
    orderLabel.textColor = ST_BLACK_COLOR;
    
    [self addSubview:orderLabel];
    
    UILabel *checkState = [UILabel new];
    
    self.checkState = checkState;
    
    checkState.font = ST_13_FONT;
    
    checkState.textAlignment = NSTextAlignmentRight;
    
    checkState.textColor = ST_EE7D21_COLOR;
    
    [self addSubview:checkState];
    
    UIImageView *iconImageView = [[UIImageView alloc]init];
    
    self.iconImageView = iconImageView;
    
    [self addSubview:iconImageView];
    
    UILabel *introduceLabel = [[UILabel alloc]init];
    
    introduceLabel.textAlignment = NSTextAlignmentLeft;
    
    introduceLabel.font = ST_13_FONT;
    
    self.introduceLabel = introduceLabel;
    
    [self addSubview:introduceLabel];
    
    UILabel *casLabel = [[UILabel alloc]init];
    
    casLabel.textAlignment = NSTextAlignmentLeft;
    
    casLabel.font = ST_12_FONT;
    
    self.casLabel = casLabel;
    
    [self addSubview:casLabel];
    
    UILabel *priceLabel = [[UILabel alloc]init];
    
    priceLabel.textAlignment = NSTextAlignmentRight;
    
    priceLabel.font = ST_13_FONT;
    
    self.priceLabel = priceLabel;
    
    [self addSubview:priceLabel];
    
    UILabel *numberLabel = [UILabel new];
    
    self.countLabel = numberLabel;
    
    numberLabel.font = ST_13_FONT;
    
    numberLabel.textAlignment = NSTextAlignmentRight;
    
    [self addSubview:numberLabel];
    
    UILabel *desLabel = [UILabel new];
    
    desLabel.textAlignment = NSTextAlignmentRight;
    
    desLabel.font = ST_13_FONT;
    
    desLabel.backgroundColor = ST_WHITE_COLOR;
    
    desLabel.textColor = ST_BLACK_COLOR;
    
    self.desLabel = desLabel;
    
    [self addSubview:desLabel];
    
    UIView *whiteView = [UIView new];
    
    whiteView.backgroundColor = ST_WHITE_COLOR;
    
    self.whiteView = whiteView;
    
    [self addSubview:whiteView];
}
- (void)updateData:(id)data {
    STOrderBean *order = data;
    
    self.order = order;
    
    self.checkState.text = @"等待审核";
    
    self.orderLabel.text = [NSString stringWithFormat:@"  订单编号:%@",order.orderNum];
    
    [self.iconImageView set_BGBannerImageViewWithString:order.goods.imgUrl];
    
    self.introduceLabel.text = order.goods.enName;
    
    self.casLabel.text = order.goods.cas;
    
    self.priceLabel.text = [NSString stringWithFormat:@"$%@元",order.goods.price];
    
    self.desLabel.text = [NSString stringWithFormat:@"共%ld间商品 合计:$%@元(含运费$%@)",[order.count integerValue],order.total,order.freight];
    
    self.countLabel.text = [NSString stringWithFormat:@"x%@",order.count];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    CGFloat margin = 10 * ST_RATE;
    
    self.orderLabel.frame = CGRectMake(0, 0, self.k_width, 60 * ST_RATE);
    CGSize size = [NSString suitToSize:@"等待审核" withSize:CGSizeMake(999, 999) andFont:ST_13_FONT andLineSpacing:3];
    
    self.checkState.frame = CGRectMake(0, 0, ST_SCREEN_WIDTH - margin, 60 * ST_RATE);
    
    self.iconImageView.frame = CGRectMake(margin, CGRectGetMaxY(self.orderLabel.frame) + margin, 120 * ST_RATE, 120 * ST_RATE);
    
    size = [NSString suitToSize:self.order.goods.enName withSize:CGSizeMake(999, 999) andFont:ST_13_FONT andLineSpacing:3];
    
    self.introduceLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + margin, CGRectGetMinY(self.iconImageView.frame), size.width, 40 * ST_RATE);
    
    self.casLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + margin, CGRectGetMaxY(self.introduceLabel.frame), size.width, 40 * ST_RATE);
    
    self.priceLabel.frame = CGRectMake(self.k_width - 120 * ST_RATE, CGRectGetMinY(self.iconImageView.frame), 100 * ST_RATE, 40 * ST_RATE);
    
    self.countLabel.frame = CGRectMake(self.k_width - 120 * ST_RATE, CGRectGetMaxY(self.priceLabel.frame) + margin, 100 * ST_RATE, 40 * ST_RATE);
    
    self.desLabel.frame = CGRectMake(0, CGRectGetMaxY(self.iconImageView.frame) + margin, ST_SCREEN_WIDTH, 60 * ST_RATE);
    self.whiteView.frame = CGRectMake(0, CGRectGetMaxY(self.desLabel.frame) , ST_SCREEN_WIDTH, 60 * ST_RATE);
    
}
@end
